'use strict';
module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable('contents', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      user_id:{
        allowNull:false,
        type:Sequelize.INTEGER
      },
      title: {
        type: Sequelize.STRING(50),
        allowNull: false
      },
      content: {
        type: Sequelize.STRING(1000),
        allowNull: false
      },
      link_count:{
        type:Sequelize.INTEGER,
        allowNull:false,
        defaultValue:0
      },
      comment_count:{
        type:Sequelize.INTEGER,
        allowNull:false,
        defaultValue:0
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    }, {
      charset: 'utf8mb4',
      collate: "utf8mb4_bin"
    });
    await queryInterface.addIndex('contents', {
      name: "user_id",
      fields: ['user_id']
    })
  },
  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('contents', []);
  }
};